package com.xiangban.service.impl;

import com.xiangban.dao.SystemMapper;
import com.xiangban.exception.BizException;
import com.xiangban.model.TSystem;
import com.xiangban.model.dto.SystemDto;
import com.xiangban.model.res.ApiResultCode;
import com.xiangban.service.SystemService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

import static com.xiangban.utils.CommonUtil.BizEmpty;

@Service
public class SystemServiceImpl implements SystemService {
    @Autowired
    private SystemMapper systemMapper;

    @Override
    public TSystem selectSystemByAccessId(TSystem tSystem) {
        TSystem tSystem1 = systemMapper.selectSystemByAccessId(tSystem);
        return tSystem1;
    }

    @Override
    public List<SystemDto> allSystemConfig() {
        SystemDto systemDto = new SystemDto();
        systemDto.setStatus(0);
        return systemMapper.allSystemConfig(systemDto);


    }

    @Override
    public SystemDto getSystemConfigByAccessId(TSystem system) {
        if (BizEmpty(system.getAccessId())){
            throw new BizException(ApiResultCode.PARAMETER_EXCEPTION);
        }
        return systemMapper.getSystemConfigByAccessId(system);
    }

    @Override
    public TSystem getSystemByAppId(String appid) {
        if (BizEmpty(appid)){
            throw new BizException(ApiResultCode.PARAMETER_EXCEPTION);
        }
        return systemMapper.getSystemByAppId(appid);
    }

}
